package com.swanclouds.redfish.systems.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.swanclouds.api.exceptions.ParameterException;
import com.swanclouds.model.systems.EthernetInterfaceConfigure;
import com.swanclouds.model.systems.builder.Oem.HuaWei.EthernetInterfaceConfigureBuider;
import com.swanclouds.redfish.common.redfish.IPv4Addresses;

/**
 * @author 张立强
 * @version jdk1.8.0
 */
public class EthernetInterfaceConfigureConcrete implements EthernetInterfaceConfigure {

    @JsonProperty("IPv4Addresses")
    private IPv4Addresses iPv4Addresses;

    @JsonProperty("LinkStatus")
    private String linkStatus;

    @JsonProperty("IsOnBoot")
    private Boolean onBoot;

    @Override
    public IPv4Addresses getIPv4Addresses() {
        return this.iPv4Addresses;
    }

    @Override
    public String getLinkStatus() {
        return this.linkStatus;
    }

    @Override
    public Boolean IsOnBoot() {
        return this.onBoot;
    }

    @Override
    public EthernetInterfaceConfigureBuider toBuilder() {
        return new EthernetInterfaceConfigureConcreteBuilder();
    }

    public static EthernetInterfaceConfigureBuider builder() {
        return new EthernetInterfaceConfigureConcrete().toBuilder();
    }

    public static enum LinkStatus {
        LinkUp,LinkDown;
    }

    public static class EthernetInterfaceConfigureConcreteBuilder implements EthernetInterfaceConfigureBuider {

        private EthernetInterfaceConfigureConcrete m;

        public EthernetInterfaceConfigureConcreteBuilder() {
            this(new EthernetInterfaceConfigureConcrete());
        }

        public EthernetInterfaceConfigureConcreteBuilder(EthernetInterfaceConfigureConcrete m) {
            this.m = m;
        }
        /**
         * IPv4地址信息 可选
         *
         * @param iPv4Addresses IPv4地址信息
         * @return this builder EthernetInterface Configure info
         */
        @Override
        public EthernetInterfaceConfigureBuider IPv4Addresses(IPv4Addresses iPv4Addresses) {
            m.iPv4Addresses = iPv4Addresses;
            return this;
        }

        /**
         * Link状态取值 可选
         *
         * @param linkStatus Link状态取值[LinkUp,LinkDown]
         * @return this builder EthernetInterface Configure info
         */
        @Override
        public EthernetInterfaceConfigureBuider LinkStatus(String linkStatus) {
            m.linkStatus = LinkStatus.valueOf(linkStatus).name();
            if (linkStatus != null && m.linkStatus == null) {
                throw new ParameterException("LinkStatus[LinkUp,LinkDown],error:" + linkStatus);
            }
            return this;
        }

        /**
         * 是否开机激活网口取值 可选
         *
         * @param onBoot [true,false]
         * @return this builder EthernetInterface Configure info
         */
        @Override
        public EthernetInterfaceConfigureBuider OnBoot(Boolean onBoot) {
            m.onBoot = onBoot;
            return this;
        }

        /**
         * Creates and return the Model Entity M
         *
         * @return M instance
         */
        @Override
        public EthernetInterfaceConfigure build() {
            return m;
        }

        /**
         * Creates a Builder using the param M as the default values
         *
         * @param in The Model M
         * @return Builder
         */
        @Override
        public EthernetInterfaceConfigureBuider from(EthernetInterfaceConfigure in) {
            m = (EthernetInterfaceConfigureConcrete) in;
            return this;
        }
    }
}
